package enumerated;

import java.util.EnumMap;
import java.util.Map;

import static enumerated.AlarmPoints.*;
import static print.Print.*;

interface Command{void action();}

public class EnumMaps {
    public static void main(String[] args) {
        EnumMap<AlarmPoints,Command> em = new EnumMap<AlarmPoints,Command>(AlarmPoints.class);
        em.put(KITCHEN, new Command() {
            @Override
            public void action() {
                print("Kitchen fire!");
            }
        });
        em.put(BATHROOM, new Command() {
            @Override
            public void action() {
                print("Bathroom alert!");
            }
        });
        for (Map.Entry<AlarmPoints,Command> entry : em.entrySet()){
            printnb(entry.getKey() + ": ");
            entry.getValue().action();
        }
        try{
            em.get(UTILITY).action();
        }catch (Exception e){
            print(e);
        }
    }
}
